home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Sherlock 2.0
/
DevLibSrc
/
Main_DevLib
/
LIBtime.c
< prev
next >
Wrap
Text File
|
1995-11-07
|
2KB
|
76 lines
/*
devlib: time routines
Do not use Sherlock in this file.
source: LIBtime.c
started: November 6, 1995.
version: November 6, 1995.
*/
#if defined(THINK_C) || defined(applec) || defined(__MWERKS__)
#include <Errors.h> /* For file errors. */
#include <OSUtils.h> /* For SysBeep. */
#endif
#include <LIBlib.h>
// #include <LIBend.h>
#include <stdio.h> /* For sprintf. */
#include <string.h> /* For strlen. */
#include <time.h>
/*
Return the print string of the current date.
See section 3.8.8 of the ANSI standard for a specification of the format.
Surround the time in quotes if quote_flag is TRUE.
*/
/* The standard abbreviations for the months. */
static char *monthname[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
char *
cvt_date(char * buffer, int buf_size, bool quote_flag)
{
time_t ltime;
struct tm * t;
int n;
time(<ime);
t = localtime(<ime);
n = sprintf(buffer, quote_flag ? "\"%3s %02d %d\"" : "%3s %02d %d",
monthname[t -> tm_mon], t -> tm_mday, 1900 + t -> tm_year);
PERM_ASSERT(n < buf_size);
return buffer;
}
/*
Return a print string of the current time.
See section 3.8.8 of the ANSI standard for a specification of the format.
Surround the date in quotes if quote_flag is TRUE.
*/
char *
cvt_time(char * buffer, int buf_size, bool quote_flag)
{
time_t ltime;
struct tm * t;
int n;
time(<ime);
t = localtime(<ime);
n = sprintf(buffer, quote_flag ? "\"%02d:%02d:%02d\"" : "%02d:%02d:%02d",
t->tm_hour, t->tm_min, t->tm_sec);
PERM_ASSERT(n < buf_size);
return buffer;
}